home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************************
-
- Utilities.c - utility routines for NTBDemo
-
- Written by Bryan K. Ressler (Beaker), 8/30/91
-
- *****************************************************************************************/
-
- /** INCLUDES ****************************************************************************/
- #include "NTBDemo.h" /* NTBDemo stuff */
- #include "NeoTextBox.h"
- #include "Utilities.h"
-
- /****************************************************************************************/
- short JustToRadio(short justification)
- {
- switch(justification) {
- case teJustLeft:
- return(kJustLeft);
- case teJustCenter:
- return(kJustCenter);
- case teJustRight:
- return(kJustRight);
- case ntbJustFull:
- return(kJustFull);
- }
- }
-
- /****************************************************************************************/
- short RadioToJust(void)
- {
- static short justifications[4] = { teJustLeft,teJustCenter,teJustRight,ntbJustFull };
-
- return(justifications[gJustRadio - kJustLeft]);
- }
-
- /****************************************************************************************/
- short RadioToFont(void)
- {
- short familyID;
-
- switch(gFontRadio) {
- case kAppFont:
- return(GetAppFont());
- case kTimes:
- GetFNum("\pTimes",&familyID); /* Zero (sys font) if not present */
- return(familyID);
- case kHelvetica:
- GetFNum("\pHelvetica",&familyID); /* Zero (sys font) if not present */
- return(familyID);
- }
- }
-
- /****************************************************************************************/
- void SetValue(DialogPtr theDialog,short itemNum,short value)
- {
- short aType;
- Rect aBox;
- Handle theItem;
-
- GetDItem(theDialog,itemNum,&aType,&theItem,&aBox);
- SetCtlValue((ControlHandle)theItem,value);
- }
-
- /****************************************************************************************/
- void GetItemRect(DialogPtr theDialog,short itemNum,Rect *box)
- {
- short aType;
- Handle theItem;
-
- GetDItem(theDialog,itemNum,&aType,&theItem,box);
- }
-
- /****************************************************************************************/
- void UserItem(DialogPtr theDialog,short itemNum,void *theProc)
- {
- short aType;
- Rect aBox;
- Handle theItem;
-
- GetDItem(theDialog,itemNum,&aType,&theItem,&aBox);
- SetDItem(theDialog,itemNum,aType,(Handle)theProc,&aBox);
- }
-
- /****************************************************************************************/
- void InvalItem(DialogPtr theDialog,short itemNum,short hInset,short vInset)
- {
- short aType;
- Rect aBox;
- Handle theItem;
-
- GetDItem(theDialog,itemNum,&aType,&theItem,&aBox);
- InsetRect(&aBox,hInset,vInset);
- InvalRect(&aBox);
- }
-
- /****************************************************************************************/
- pascal void BoxItem(WindowPtr theWindow,short itemNum)
- {
- short aType;
- Rect theBox;
- Handle aHandle;
-
- GetDItem(theWindow,itemNum,&aType,&aHandle,&theBox);
- PenNormal();
- ForeColor(blackColor);
-
- FrameRect(&theBox);
- }
-
- /****************************************************************************************/
- pascal void GrayBoxItem(WindowPtr theWindow,short itemNum)
- {
- short aType;
- Rect theBox;
- Handle aHandle;
-
- GetDItem(theWindow,itemNum,&aType,&aHandle,&theBox);
- PenNormal(); PenPat(&qd.gray);
- ForeColor(blackColor);
-
- FrameRect(&theBox);
- PenNormal();
- }
-
- /****************************************************************************************/
- void TextParms(short code)
- {
- static short txFont,txFace,txSize,txMode;
-
- if (code == kSave) { /* Save current port's text parameters */
- txFont = qd.thePort->txFont;
- txFace = qd.thePort->txFace;
- txSize = qd.thePort->txSize;
- txMode = qd.thePort->txMode;
- } else { /* Restore current port's text parameters */
- TextFont(txFont);
- TextFace(txFace);
- TextSize(txSize);
- TextMode(txMode);
- }
- }
-